<?php
class Feedback
{
	public $Table="feedback";
	public $FeedbackID;
	public $ProductID;
	public $Name;
	public $Email;
	public $Phone;
	public $Country;
	public $Comment;
	public $Status;
	public $LastUpdate;
	function loadByKey($id)
	{
		$ob=new ClassConnect();
		$sql="select * from `".$this->Table."` where FeedbackID='".$id."'";
		$row=$ob->singleData($sql);
		$this->FeedbackID=$row['FeedbackID'];
		$this->ProductID=$row['ProductID'];
		$this->Name=$row['Name'];
		$this->Email=$row['Email'];
		$this->Phone=$row['Phone'];
		$this->Country=$row['Country'];
		$this->Comment=$row['Comment'];
		$this->Status=$row['Status'];
		$this->LastUpdate=$row['LastUpdate'];
	}
	function getTable($dk)
	{
		$ob=new ClassConnect();
		$sql="select * from `".$this->Table."` $dk";
		$data=$ob->mutiData($sql);
		return $data;
	}
	function travel($dk)
	{
		$arr=array();
		$data=$this->getTable($dk);
		for($i=0;$i<count($data);$i++)
			array_push($arr,$data[$i]['FeedbackID']);
		return $arr;
	}
	function insert($conn)
	{
		$ob=new ClassConnect();
		$dt=new ClassDateTime();
		$this->LastUpdate=$dt->_getNow("-");
		$this->FeedbackID=$ob->getNextId($this->Table,"FeedbackID");
		$field=array(
						"FeedbackID",
						"ProductID",
						"Name",
						"Email",
						"Phone",
						"Country",
						"Comment",
						"Status",
						"LastUpdate");
		$value=array(
						$this->FeedbackID,
						$this->ProductID,
						$this->Name,
						$this->Email,
						$this->Phone,
						$this->Country,
						$this->Comment,
						$this->Status,
						$this->LastUpdate);
						
		return $ob->insertData($conn,$this->Table,$field,$value);
	}
	function update($conn)
	{
		$ob=new ClassConnect();
		$obj = new Feeback();
		$dt=new ClassDateTime();
		
		$field=array(
						"FeedbackID",
						"ProductID",
						"Name",
						"Email",
						"Phone",
						"Country",
						"Comment",
						"Status",
						"LastUpdate");
		$value=array(
						$this->FeedbackID,
						$this->ProductID,
						$this->Name,
						$this->Email,
						$this->Phone,
						$this->Country,
						$this->Comment,
						$this->Status,
						$this->LastUpdate);
						
		$where="FeedbackID = '".$this->FeedbackID."'";
		return $ob->updateData($conn,$this->Table,$field,$value,$where);			
	}
	
	function delete($conn)
	{
		$ob=new ClassConnect();	
		$where="FeedbackID = '".$this->FeedbackID."'";
		return $ob->deleteData($conn,$this->Table,$where);
			
	}

}
?>
